class YahooMap():

	def __init__(self, key, height=100, width=100, unit='%', html_id='map', location="Vancouver", html_class='', zoom=3):
		self.key = key
		self.height = height
		self.width = width
		self.unit = unit
		self.location= location
		self.zoom = zoom
		self.html_id = html_id
		self.html_class = html_class

	def init_script_tag(self):
		return '<script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=%(key)s;"></script>' % {'key':self.key}

	def style_tag(self):
		return """
<style type="text/css">
	#%(html_id)s{height:%(height)i%(unit)s;width:%(width)i%(unit)s}
</style>""" % {'height':self.height,'width':self.width,'unit':self.unit,'html_id':self.html_id}

	def map_tag(self):
		return '<div id="%(html_id)s" class="%(html_class)s"></div>' % {'html_id':self.html_id,'html_class':self.html_class}
		
	def script_tag(self):
		return """
<script type="text/javascript">  
	var map = new YMap(document.getElementById(\'%(html_id)s\'));  
	map.addTypeControl();  
	map.setMapType(YAHOO_MAP_REG);  
	map.drawZoomAndCenter("%(location)s", %(zoom)i);  
</script>""" % {'html_id':self.html_id,'location':self.location,'zoom':self.zoom}

	def test(self):
		return """
<html>
	<head>
		%(init)s
		%(style)s
	</head>
	<body>
		%(map)s
		%(script)s
	</body>
</html>""" % {'init':self.init_script_tag(),'style':self.style_tag(),'map':self.map_tag(),'script':self.script_tag()}


if __name__ == "__main__":

	YAHOO_KEY = ''

	ym = YahooMap(key=YAHOO_KEY)
	print ym.test()